//
//  XLHttpRequest.h
//  MPTinyAppLearn
//
//  Created by xl on 2019/11/7.
//  Copyright © 2019 xl. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "XLNetworkingConfig.h"


typedef void(^XLResponseSuccessBlock)(NSDictionary *dict);

typedef void(^XLResponseFailBlock)(XLServerRequestsStatus status, XLNetworkReachabilityStatus reachability, NSError *error, NSDictionary *dict);

typedef void (^XLProgressBlock)(int_fast64_t bytesRead, int_fast64_t totalBytesRead);


@interface XLHttpRequest : NSObject
/** 请求域名 */
@property (nonatomic, copy) NSString *baseUrl;
/** 请求头 */
@property (nonatomic, copy) NSDictionary *headersParams;
/** 当前请求超时时间(默认10s) */
@property (nonatomic, assign) NSTimeInterval timeout;
/** 服务器无响应，防止多次请求 */
@property (nonatomic, assign) BOOL isFilter;

/** 用于普通请求get/post */
- (void)requestWithMethod:(XLHttpMedthType)method
                      url:(NSString *)url
                   params:(NSDictionary *)params
            isExtraParams:(BOOL)isExtraParams
             successBlock:(XLResponseSuccessBlock)successBlock
                failBlock:(XLResponseFailBlock)failBlock;

/** 用于显示进度请求get/post */
- (void)requestWithMethod:(XLHttpMedthType)method
                      url:(NSString *)url
                   params:(NSDictionary *)params
             successBlock:(XLResponseSuccessBlock)successBlock
                failBlock:(XLResponseFailBlock)failBlock
            progressBlock:(XLProgressBlock)progressBlock;

/** 用于上传一张图片post */
- (void)requestWithMethod:(XLHttpMedthType)method
                      url:(NSString *)url
                   params:(NSDictionary *)params
                    image:(UIImage *)image
                 fileName:(NSString *)fileName
                     name:(NSString *)name
             successBlock:(XLResponseSuccessBlock)successBlock
                failBlock:(XLResponseFailBlock)failBlock
            progressBlock:(XLProgressBlock)progressBlock;



@end


